﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace DeploymentMaxLib.Actions
{
    public class ActionTFS : ActionBase
    {
        /// <summary>
        /// http://msdn.microsoft.com/en-us/magazine/cc163498.aspx
        /// </summary>
        public override string LongName
        {
            get { return Common.Constants.LongName; }
        }

        public override string Description
        {
            get { return Common.Constants.Description; }
        }

        public override ActionResponse Execute(ActionRequest pActionRequest)
        {

            base.Result = Validate(pActionRequest);

            if (!base.Result.HasErrorOrCritical())
            {
                var tExecutionType = pActionRequest.ExecutionType.ToEnum<Common.ExecutionType>();

                switch (tExecutionType)
                {
                    case Common.ExecutionType.ApplyLabel:
                        {
                        } break;
                    case Common.ExecutionType.GetLatestVersion:
                        {
                        } break;
                }
            }

            return pActionRequest.GetResponse(this);
        }

        public ActionResult GetLatestVersion()
        {
            var url = "";

            var server = Microsoft.TeamFoundation.Client.TeamFoundationServerFactory.GetServer(url);

            server.Authenticate();

            return null;
        }


        public ActionResult ApplyLabel()
        {
            return null;
        }


        public static class Common
        {
            public enum ExecutionType
            {
                None = 0,
                ApplyLabel = 1,
                GetLatestVersion = 2
            }

            public static class Constants
            {
                public const string LongName = "Team Foundation";
                public const string Description = "Handles Team Foundation apply label, get latest version actions.";
            }
        }



        public override ActionResult Validate(ActionRequest pRequest)
        {
            throw new NotImplementedException();
        }
    }
}
